package system;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import cards.Card;
import cards.CardType;

public class TestCentralSystem {
	
	
	CentralSystem system;
	
	@Before
	public void init() {
		system = new CentralSystem();
	}
	
	@Test
	public void testRestMoneyWhenBuyCardWithoutMoney() {
		CentralSystem.Response response = system.buyCard(CardType.COMMON_10, 0);
		int expectedRestMoney = 0;
		int actualRestMoney = response.restMoney;
		assertEquals(expectedRestMoney, actualRestMoney);
	}
	
	@Test
	public void testRestMoneyWhenBuyCardWithoutRestMoney() {
		CentralSystem.Response response = system.buyCard(CardType.COMMON_10, CardType.COMMON_10.getCost());
		int expectedRestMoney = 0;
		int actualRestMoney = response.restMoney;
		assertEquals(expectedRestMoney, actualRestMoney);
	}
	@Test
	public void testRestMoneyWhenBuyCardWithRestMoney() {
		CentralSystem.Response response = system.buyCard(CardType.COMMON_10, CardType.COMMON_10.getCost()+10);
		int expectedRestMoney = 10;
		int actualRestMoney = response.restMoney;
		assertEquals(expectedRestMoney, actualRestMoney);
	}
	@Test
	public void testNoCardWhenBuyCardWithoutMoney() {
		CentralSystem.Response response = system.buyCard(CardType.COMMON_10, 0);
		Card actualCard = response.card;
		assertNull(actualCard);
	}
	@Test
	public void testNoCardWhenBuyCardWithLessMoney() {
		CentralSystem.Response response = system.buyCard(CardType.COMMON_10, CardType.COMMON_10.getCost()-10);
		Card actualCard = response.card;
		assertNull(actualCard);
	}
	@Test
	public void testHaveCardWhenBuyCardWithCorrectMoney() {
		CentralSystem.Response response = system.buyCard(CardType.COMMON_10, CardType.COMMON_10.getCost());
		Card actualCard = response.card;
		assertNotNull(actualCard);
	}
	@Test
	public void testHaveCardWhenBuyCardWithRestMoney() {
		CentralSystem.Response response = system.buyCard(CardType.COMMON_10, CardType.COMMON_10.getCost()+15);
		Card actualCard = response.card;
		assertNotNull(actualCard);
	}
	
}
